<?php

namespace Home\Controller;

use Think\Controller;

class BaseController extends Controller
{

    protected $user;

    public function __construct()
    {
        parent::__construct();
        $value = session('user');
        if (!$value) {
            $this->error('请登录', '/home/auth/login');
        }
        $this->user = $value;
        $this->assign('loginUser', $this->user);
    }


    public function retSuccess()
    {
        $data['code'] = 0;
        $data['msg'] = '操作成功';
        $this->ajaxReturn($data);
    }

    public function retError($msg)
    {
        $data['code'] = -1;
        $data['msg'] = $msg;
        $this->ajaxReturn($data);
    }
}